Skip to content

Audioreactive bugfix: auto-suspend in all realtime modes, but stay active when "Use main segment only"#5599

Merged
softhack007 merged 4 commits into
mainfrom
AR_realtimemodes_update
May 15, 2026
Merged

Audioreactive bugfix: auto-suspend in all realtime modes, but stay active when "Use main segment only"#5599
softhack007 merged 4 commits into
mainfrom
AR_realtimemodes_update

Conversation

@softhack007
Copy link
Copy Markdown
Member

@softhack007 softhack007 commented May 11, 2026

  • fixes a minor problem with newer realtime modes (DDP, TPM2NET and DMX) not causing auto-suspend of sound processing (thanks @blazoncek for the hint).
  • ensure that AR audio stays active when "Use main segment only" (other segments are still controlled locally)
  • small update for better compatibility with V5 builds

NB: the impact on users is minimal, especially on esp32 and esp32-s3 - audioreactive FFT does not use much CPU time on these boards (less than 20%). Any way the fix can be applied to 16.0.0, 17.0.0 and 0.15.5 in the same way.

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility across ESP-IDF framework versions for audio processing.
    • More reliable UDP buffer handling when discarding invalid packets and clearing unread input to prevent receive hiccups.
    • Simplified realtime-mode gating so local FFT/audio processing reliably suspends and resumes.
    • Ensure audio processing task runs at least once during device updates to avoid missed audio work.

Review Change Stack

* Modernize auto-suspend condition - DDP, DMX and TPM2NET were missing (thanks @blazoncek for the hint)
@softhack007 softhack007 requested a review from DedeHai May 11, 2026 15:48
@softhack007

This comment was marked as duplicate.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 34336ddb-b7a7-4647-a007-9ec56ffea76a

📥 Commits

Reviewing files that changed from the base of the PR and between e59ecaf and 4c78949.

📒 Files selected for processing (1)
  • usermods/audioreactive/audio_reactive.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • usermods/audioreactive/audio_reactive.cpp

Walkthrough

Updated audio_reactive.cpp to add ESP-IDF version-conditional UDP buffer handling (use flush() for ESP-IDF < 5, clear() for v5+), simplified realtime-mode gating to a single predicate, and ensured disableSoundProcessing is cleared on ESP32 onUpdateBegin() so FFT runs once when enabled.

Changes

Audioreactive UDP Buffer Management and Realtime Mode Gating

Layer / File(s) Summary
Realtime Mode Gating Logic
usermods/audioreactive/audio_reactive.cpp
loop() realtime-mode suspension simplified to realtimeMode && !realtimeOverride && !useMainSegmentOnly; onUpdateBegin() (ESP32 path) now sets disableSoundProcessing = false when enabled so FFT_Task can run once.
UDP Buffer Version-Specific Handling
usermods/audioreactive/audio_reactive.cpp
receiveAudioData() invalid-packet discard and loop() receive-mode no-packet paths now use fftUdp.flush() for ESP_IDF_VERSION_MAJOR < 5 and fftUdp.clear() for ESP-IDF v5+, replacing unconditional flush() calls.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • wled/WLED#5357: Also modifies ESP32 audioreactive-related code and adjusts ESP-IDF version guards in audio-related headers.

Suggested labels

bug, usermod

Suggested reviewers

  • DedeHai
  • netmindz
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and concisely describes the primary bugfix: ensuring audio remains active when 'Use main segment only' is enabled while auto-suspending in realtime modes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as resolved.

@softhack007 softhack007 changed the title Audioreactive bugfix: auto-suspend in all realtime modes Audioreactive bugfix: auto-suspend in all realtime modes, but stay active when "Use main segment only" May 11, 2026
@softhack007

This comment was marked as outdated.

@coderabbitai

This comment was marked as outdated.

@coderabbitai coderabbitai Bot added bug usermod usermod related labels May 11, 2026
@softhack007 softhack007 added this to the 16.0.0 release + bugfixes milestone May 11, 2026
@blazoncek
Copy link
Copy Markdown
Contributor

The code for handling disableSoundProcessing is IMO unnecessary for realtime modes. It can be done in FFT task.
The same is true for update and sync receiving.
Rearranging checks (and flags) can save and simplify some code in that case.

The only benefit (I see) is to notify UI (and even in this scenario there is already ... (disableSoundProcessing == false) && !(audioSyncEnabled & 0x02) ... in place elsewhere in the code).

There are also a other bugs related to current use of disableSoundProcessing. One of them is in onUpdateBegin() which will set it to false even when in sync receive mode (the attempted fix in loop() is prone to race condition).

If you want to keep disableSoundProcessing then consolidate how and when it is set by using just one entry point.

@softhack007
Copy link
Copy Markdown
Member Author

softhack007 commented May 15, 2026

If you want to keep disableSoundProcessing then consolidate how and when it is set by using just one entry point.

@blazoncek to be honest with you, this comment does not make much sense to me. You know who designed AR and where it comes from. I still doubt that you have the necessary understanding to instruct me how AR should be coded.

If you know about real bugs, please do what everybody else does - open a ticket with a step-by-step scenario, screenshots etc. Then we can discuss.

The style you show here is not helpful at all. In February 2026 you told me clearly (in another issue discussion) that we should not even ask you for anything related to WLED -"live with that" were your own words.

@blazoncek
Copy link
Copy Markdown
Contributor

I am sorry. You will not hear from me any more.

explain rationale behind one line that differs from 8266 code.
The initial "unlock" ensures that FFT_Task can initialize even when in sound receive mode -> might cause some RAM allocation even when not strictly needed, but also ensures a clean start-up of audio processing.
}
micDataReal = 0.0f; // just to be sure
if (enabled) disableSoundProcessing = false;
if (enabled) disableSoundProcessing = false; // allows FFT_Task to run at least once, even when loop() might disable again
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: this is safe even with "init == true" => init leads to vTaskSuspend(FFT_Task) so no FFT can run during OTA.

@softhack007
Copy link
Copy Markdown
Member Author

tested, works as expected.

@softhack007 softhack007 merged commit 91bcfc1 into main May 15, 2026
56 checks passed
softhack007 added a commit that referenced this pull request May 15, 2026
…tive when "Use main segment only" (#5599)

* fixes a minor problem with newer realtime modes (DDP, TPM2NET and DMX) not causing auto-suspend of sound processing.
* ensure that AR audio stays active when "Use main segment only" (other segments are still controlled locally)
* small update for better compatibility with V5 builds
@softhack007 softhack007 deleted the AR_realtimemodes_update branch May 15, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug usermod usermod related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants